/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javamail.sdp.util;

/**
 *
 * @author sriram
 */
public enum eSdpHeader {
    //TODO: Implement javax SDP packages instead of redefining stuff.
    NIL(0, ""),
    VERSION(1, "v"), 
    ORIGINATOR(2,"o"), 
    NAME(3, "s"), 
    CONNECT(4, "c"), 
    TIME(5, "t"), 
    MEDIA(6, "m"),
    ATTRIBUTE(7, "a");
    
    private final int index;
    private final String str;
    
    eSdpHeader(int index, String string) {
        this.index = index;
        this.str = string;
    }
    
    public int toInt() {
        return index;
    }
 
    @Override
    public String toString() {
        return str;
    }
    
    public static eSdpHeader fromString(String headerName) {
        //Convert to Lower case and trim the string
        headerName = headerName.toLowerCase().trim();
        for (eSdpHeader head : eSdpHeader.values()) {
            if(headerName.equals(head.toString().trim().toLowerCase()))
                return head;
        }
        return NIL;
    }
}
